package com.godz.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.mapper.*;
import com.godz.pojo.GodzEdu;
import com.godz.pojo.GodzJob;
import com.godz.pojo.GodzTitle;
import com.godz.pojo.HfuuLife;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class textController {
    @Autowired
    GodzEduMapper godzEduMapper;
    @Autowired
    GodzGodMapper godzGodMapper;
    @Autowired
    GodzIndexMapper godzIndexMapper;
    @Autowired
    GodzJobMapper godzJobMapper;
    @Autowired
    GodzPosMapper godzPosMapper;
    @Autowired
    GodzTitleMapper godzTitleMapper;
    @Autowired
    HfuuLifeMapper hfuuLifeMapper;
    @RequestMapping("/text")
    public String text(){
        return  "text";
    }

    @GetMapping("/godzJob/{id}")
    public String text(@PathVariable("id")Integer id, Model model){
        //标题栏数据
        List<GodzTitle> titles = godzTitleMapper.selectList(null);
        model.addAttribute("title",titles);

        GodzJob selectOne = godzJobMapper.selectOne(new QueryWrapper<GodzJob>().eq("id", id));
        model.addAttribute("job",selectOne);
        return "text";
    }

    @GetMapping("/hfuulife/{id}")
    public String life(@PathVariable("id")Integer id, Model model){
        //标题栏数据
        List<GodzTitle> titles = godzTitleMapper.selectList(null);
        model.addAttribute("title",titles);
        //数据
        HfuuLife life = hfuuLifeMapper.selectOne(new QueryWrapper<HfuuLife>().eq("id", id));
        model.addAttribute("job",life);
        return "text2";
    }

    @GetMapping("/godzEdu/{id}")
    public String Edu(@PathVariable("id")Integer id, Model model){
        //标题栏数据
        List<GodzTitle> titles = godzTitleMapper.selectList(null);
        model.addAttribute("title",titles);
        //数据
        GodzEdu edu = godzEduMapper.selectOne(new QueryWrapper<GodzEdu>().eq("id", id));
        model.addAttribute("job",edu);
        return "text3";
    }
}
